/*
 * Copyright (c) 2007-2020 西安交通信息投资营运有限公司 版权所有
 */

package com.xci.edu.core.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.github.lvyanyang.core.BaseEntity;
import com.github.lvyanyang.core.Const;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;

import java.util.Date;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 学员学时明细
 * @author 焦元义 jiaoyuanyi@xci96716.com
 * @since 2020-11-24 15:14:37
 */
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(description = "学员学时明细")
public class EduStudentPeriodDetails extends BaseEntity {
    /**
     * 主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ExcelIgnore
    @Excel(name = "主键", width = 20d)
    @ApiModelProperty(value = "主键", position = 1)
    private Long id;

    /**
     * 课件主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @Excel(name = "课件主键", width = 20d)
    @ApiModelProperty(value = "课件主键", position = 2)
    private Long coursewareId;

    /**
     * 课件名称
     */
    @Length(max = 50, message = "课件名称长度不能超过{max}个字符")
    @Excel(name = "课件名称", width = 20d)
    @ApiModelProperty(value = "课件名称", position = 3)
    private String coursewareName;

    /**
     * 学员主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "学员主键不能为空")
    @Excel(name = "学员主键", width = 20d)
    @ApiModelProperty(value = "学员主键", required = true, position = 4)
    private Long studentId;

    /**
     * 学员姓名
     */
    @NotBlank(message = "学员姓名不能为空")
    @Length(max = 50, message = "学员姓名长度不能超过{max}个字符")
    @Excel(name = "学员姓名", width = 20d)
    @ApiModelProperty(value = "学员姓名", required = true, position = 5)
    private String studentName;

    /**
     * 学习方式
     */
//    @NotBlank(message = "学习方式不能为空")
    @Length(max = 50, message = "学习方式长度不能超过{max}个字符")
    @Excel(name = "学习方式", width = 20d)
    @ApiModelProperty(value = "学习方式", required = true, position = 6)
    private String studyCategory;

    /**
     * IP地址
     */
//    @NotBlank(message = "IP地址不能为空")
    @Length(max = 50, message = "IP地址长度不能超过{max}个字符")
    @Excel(name = "IP地址", width = 20d)
    @ApiModelProperty(value = "IP地址", required = true, position = 7)
    private String ip;

    /**
     * 签到时间
     */
    @NotNull(message = "签到时间不能为空")
    @Excel(name = "签到时间", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "签到时间", required = true, position = 8)
    private Date signInDateTime;

    /**
     * 签退时间
     */
    @NotNull(message = "签退时间不能为空")
    @Excel(name = "签退时间", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "签退时间", required = true, position = 9)
    private Date signOutDateTime;

    /**
     * 总学习时长(秒)
     */
    @NotNull(message = "学习时长(秒)不能为空")
    @Excel(name = "学习时长(秒)", width = 20d)
    @ApiModelProperty(value = "学习时长(秒)", required = true, position = 10)
    private Integer allPeriod;

    /**
     * 学习时长(秒)
     */
    @NotNull(message = "学习时长(秒)不能为空")
    @Excel(name = "学习时长(秒)", width = 20d)
    @ApiModelProperty(value = "学习时长(秒)", required = true, position = 10)
    private Integer period;

    /**
     * 操作时间
     */
//    @NotNull(message = "操作时间不能为空")
    @Excel(name = "操作时间", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "操作时间", required = true, position = 11)
    private Date operateDateTime;

    /**
     * 操作日期
     */
//    @NotNull(message = "操作日期不能为空")
    @Excel(name = "操作日期", width = 20d, exportFormat = Const.DEFAULT_DATETIME_PATTERN)
    @ApiModelProperty(value = "操作日期", required = true, position = 12)
    private Date operateDate;

    /**
     * 课件类型[0-图片, 1-视频]
     */
    @Length(max = 50, message = "课件类型长度不能超过{max}个字符")
    @Excel(name = "课件类型", width = 20d, replace = { "图片_0", "视频_1" })
    @ApiModelProperty(value = "课件类型[0-图片, 1-视频]", required = true, position = 6)
    private String courseType;

    /***
     * 是否图片课件
     */
    @ApiModelProperty("图片课件")
    public Boolean getIfPPT() {
        if (this.courseType.equals("0")){
            return true;
        }else{
            return false;
        }
    }

    /***
     * 是否视频课件
     */
    @ApiModelProperty("视频课件")
    public Boolean getIfVideo() {
        if (this.courseType.equals("1")){
            return true;
        }else{
            return false;
        }
    }

}
